package edu.jamestang.yeb.controller;

import edu.jamestang.yeb.entity.Department;
import edu.jamestang.yeb.service.DepartmentService;
import edu.jamestang.yeb.util.Resp;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author JamesTang
 * @date 2021/12/16 1:52
 */
@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @ApiOperation(value = "Get all department")
    @GetMapping("/")
    public List<Department> getAllDepartment(){
        return departmentService.getAllDepartments();
    }

    @ApiOperation("Add department")
    @PostMapping("/")
    public Resp addDep(@RequestBody Department department){
        return departmentService.addDep(department);
    }

    @ApiOperation(value = "Delete Department")
    @DeleteMapping("/{id}")
    public Resp deleteDep(@PathVariable Integer id){
        return departmentService.deleteDep(id);
    }
}
